import 'package:syn_4s/core/model/project_model.dart';

import '../constants/sp_key.dart';
import '../model/base/api_result_data.dart';
import '../model/short_model.dart';
import '../utils/dio_utils.dart';
import '../utils/sp_utils.dart';

class ComboRequest {
  static Future<ApiResultData<List<ShortModel>>> getComboWithProjId(
      String typeKey) async {
    String siteId = await SPUtils.get(keyProjId);
    final result = await DioUtils.instance
        .requestBaseUrl("/api/utils/combos?typeKey=$typeKey&typeKeyId=$siteId");
    ApiResultData<List<ShortModel>> apiResultData =
        ApiResultData<List<ShortModel>>.fromListJson(
            result,
            (data) => data
                .map(
                    (item) => ShortModel.fromJson(item as Map<String, dynamic>))
                .toList());
    // 2.json转model
    return apiResultData;
  }

  static Future<ApiResultData<List<ShortModel>>> getCombo(
      String typeKey) async {
    final result = await DioUtils.instance
        .requestBaseUrl("/api/utils/combos?typeKey=$typeKey");
    ApiResultData<List<ShortModel>> apiResultData =
        ApiResultData<List<ShortModel>>.fromListJson(
            result,
            (data) => data
                .map(
                    (item) => ShortModel.fromJson(item as Map<String, dynamic>))
                .toList());
    // 2.json转model
    return apiResultData;
  }
}
